{template 'common/header'}
<ul class="nav nav-tabs">
    <li {if $foo == 'post' && empty($id)}class="active"{/if}> <a href="{php echo $this->createWebUrl('Hutui', array('foo' => 'post'));}">添加推荐微信</a>
    </li>
	<li {if $foo == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('Hutui', array('foo' => 'display'));}">推荐微信列表</a>
    </li>
    {if !empty($id) && $foo == 'post'}
    <li class="active"> <a href="{php echo $this->createWebUrl('Hutui',array('foo'=>'post','id'=>$id));}"> 编辑推荐微信  </a> </li>
    {/if}
</ul>
<style>
.table td span{display:inline-block;margin-top:4px;}
.table td input{margin-bottom:0;}
</style>
{if $foo == 'display'}
<link rel="stylesheet" href="../addons/amouse_article/style/css/jquery-ui-tooltip.min.css?v=20140603" />
<script type="text/javascript" src="../addons/amouse_article/style/css/jquery-ui-tooltip.min.js?v=20140601" ></script>
<div class="panel panel-info">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="./index.php" method="get" class="form-horizontal" role="form">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="amouse_article" />
            <input type="hidden" name="do" value="hutui" />
            <input type="hidden" name="op" value="display" />

            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 control-label">关键字</label>
                <div class="col-sm-8 col-md-8 col-lg-8">
                    <input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
                </div>
            </div>

            <div class="form-group">
                <div class="pull-right col-xs-12 col-sm-2 col-md-2 col-lg-2">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table">
            <thead>
            <tr>
                <th>标题</th>
                <th style="width:180px;">缩略图</th>
                <th>创建时间</th>
                <th>是否推荐</th>
                <th style="text-align:right;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $item}
            <tr>
                <td>
                    {$item['title']}
                </td>
                <td  class="qrcode">
                    <img src="{$_W['attachurl']}{$item['thumb']}" height="45px" width="45px" />
                </td>
                <td>{php echo date('Y-m-d H:i',$item['createtime'])}</td>
                <td>
                    {if $item['hot']==0}<span class="label label-default label-info">未推荐</span>{/if}
                    {if $item['hot']==1}<span class="label label-success">推荐</span>{/if}
                </td>
                <td style="text-align:right;">
                    <a href="{php echo $this->createWebUrl('hutui', array('foo' => 'post', 'id' => $item['id']))}" title="编辑" class="btn btn-mini"><i class="fa fa-edit"></i></a>
                    {if $item['hot']==0}
                    <a href="{php echo $this->createWebUrl('hutui', array('foo' => 'recommed','hot'=>1, 'id' => $item['id']))}" title="推荐" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="推荐" >
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    {/if}
                    {if $item['hot']==1}
                    <a href="{php echo $this->createWebUrl('hutui', array('foo' => 'recommed','hot'=>0, 'id' => $item['id']))}" title="取消推荐" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="取消推荐" >
                        <i class="fa fa-chevron-down"></i>
                    </a>
                    {/if}
                    <a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWebUrl('hutui', array('foo' => 'delete', 'id' => $item['id']))}" title="删除" class="btn btn-mini"><i class="fa fa-times"></i></a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
</div>
{$pager}
<script type="text/javascript">
    require(['bootstrap'],function($){
        $('.btn').hover(function(){
            $(this).tooltip('show');
        },function(){
            $(this).tooltip('hide');
        });
    });
    $("td.qrcode").tooltip({
        items:'img',
        content: function() {
            return "<img width='300px' height='300px' src='"  + $(this).attr("src") + "'></img>";
        },
        position: {
            my : "right bottom-300",
            collision: "fit"
        }
    });

</script>
{elseif $foo == 'post'}
<div class="clearfix">
    <form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
        <div class="panel panel-default">
		<input type="hidden" name="id" value="{$item[id]}">
            <div class="panel-heading">推荐微信管理</div>
            <div class="panel-body">
                <input type="hidden" name="id" value="{$item[id]}">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">标题</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" placeholder="" name="title" value="{$item['title']}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">缩略图</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image('thumb', $item['thumb'])}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"> 引导关注</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" placeholder="" name="guanzhuUrl" value="{$item['guanzhuUrl']}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">简介</label>
                    <div class="col-sm-8">
                        <textarea class="form-control richtext" name="description" rows="10">{$item['description']}</textarea>
                    </div>
                </div>

            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>

	</form>
</div>
{/if}
{template 'common/footer'}